using Microsoft.AspNetCore.Mvc;
using JTZY.Model.Order.Dto;
using JTZY.Model.Order;
using JTZY.Service.Order.IOrderService;
using JTZY.Admin.WebApi.Filters;

//创建时间：2025-02-26
namespace JTZY.Admin.WebApi.Controllers.Order
{
    /// <summary>
    /// 退货物码明细
    /// </summary>
    [Verify]
    [Route("order/Refshipdetail")]
    public class RefshipdetailController : BaseController
    {
        /// <summary>
        /// 退货物码明细接口
        /// </summary>
        private readonly IRefshipdetailService _RefshipdetailService;

        public RefshipdetailController(IRefshipdetailService RefshipdetailService)
        {
            _RefshipdetailService = RefshipdetailService;
        }

        /// <summary>
        /// 查询退货物码明细列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "refshipdetail:list")]
        public IActionResult QueryRefshipdetail([FromQuery] RefshipdetailQueryDto parm)
        {
            var response = _RefshipdetailService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询退货物码明细详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "refshipdetail:query")]
        public IActionResult GetRefshipdetail(long Id)
        {
            var response = _RefshipdetailService.GetInfo(Id);
            
            var info = response.Adapt<RefshipdetailDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加退货物码明细
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "refshipdetail:add")]
        [Log(Title = "退货物码明细", BusinessType = BusinessType.INSERT)]
        public IActionResult AddRefshipdetail([FromBody] RefshipdetailDto parm)
        {
            var modal = parm.Adapt<Refshipdetail>().ToCreate(HttpContext);

            var response = _RefshipdetailService.AddRefshipdetail(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新退货物码明细
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "refshipdetail:edit")]
        [Log(Title = "退货物码明细", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateRefshipdetail([FromBody] RefshipdetailDto parm)
        {
            var modal = parm.Adapt<Refshipdetail>().ToUpdate(HttpContext);
            var response = _RefshipdetailService.UpdateRefshipdetail(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除退货物码明细
        /// </summary>
        /// <returns></returns>
        [HttpPost("delete/{ids}")]
        [ActionPermissionFilter(Permission = "refshipdetail:delete")]
        [Log(Title = "退货物码明细", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteRefshipdetail([FromRoute]string ids)
        {
            var idArr = Tools.SplitAndConvert<long>(ids);

            return ToResponse(_RefshipdetailService.Delete(idArr));
        }

    }
}